const getDefaultState = () => {
  return {
    mapReady: false,
    geoJsonShow: false,
    geoJsonBaseUrl: [],
  }
}

const state = getDefaultState()

const mutations = {
  SET_MAP_READY: (state, ready) => {
    state.mapReady = ready
  },
  SET_GEOJSON_SHOW: (state, show) => {
    state.geoJsonShow = show
  },
  SET_GEOJSON_URL: (state, geoJsonBaseUrl) => {
    state.geoJsonBaseUrl = geoJsonBaseUrl
  },
}

const actions = {
  // 设置geoJsonEntity组件可见性
  setGeoJsonShow({ commit }, show) {
    return new Promise(resolve => {
      commit('SET_GEOJSON_SHOW', show)
      resolve()
    })
  },
  setGeoJsonBaseUrl({ commit }, geoJsonBaseUrl) {
    return new Promise(resolve => {
      commit('SET_GEOJSON_URL', geoJsonBaseUrl)
      resolve()
    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
